package com.koudai.finance.enums;

/**
 * API 统一返回状态码
 */
public enum ResultCode {

    SUCCESS(200, "成功"),
    PARAM_IS_INVALID(10001, "请求参数错误"),
    SIGN_ERROR(10002, "签名错误"),

    /* 用户错误：20001-29999*/
    USER_NOT_LOGGED_IN(20001, "用户未登录"),
    USER_ACCOUNT_FORBIDDEN(20003, "账号已被禁用"),
    USER_NOT_EXIST(20004, "该用户不存在，请联系管理员"),
    USER_HAS_EXISTED(20005, "该用户已存在"),
    USER_PHONE_EXISTED(20006, "该手机号已注册"),
    USER_NAME_CARD_NOT_MATCH(20007, "身份证号和姓名不匹配"),
    USER_ID_CARD_EXISTED(20008, "身份证号已存在"),
    USER_LOGIN_ERROR(20009, "登录异常"),
    USER_NOT_REAL(20010, "用户未实名"),

    /* 业务错误：30001-39999 */
    SPECIFIED_QUESTIONED_USER_NOT_EXIST(30001, "某业务出现问题"),

    /* 系统错误：40001-49999 */
    SYSTEM_INNER_ERROR(40001, "系统繁忙，请稍后重试"),
    SYSTEM_IN_MAINTENANCE(40002, "系统维护中"),
    SYSTEM_IS_TOO_BUSY(40003, "操作频繁，请稍候再试"),

    /* 数据错误：50001-599999 */
    RESULT_DATA_NONE(50001, "未查询到相关信息"),
    DATA_IS_WRONG(50002, "填写信息有误"),
    DATA_ALREADY_EXISTED(50003, "数据已存在"),

    /* 接口错误：60001-69999 */
    INTERFACE_INNER_INVOKE_ERROR(60001, "内部系统接口调用异常"),
    INTERFACE_OUTTER_INVOKE_ERROR(60002, "外部系统接口调用异常"),
    INTERFACE_FORBID_VISIT(60003, "该接口禁止访问"),
    INTERFACE_ADDRESS_INVALID(60004, "接口地址无效"),
    INTERFACE_REQUEST_TIMEOUT(60005, "接口请求超时"),
    INTERFACE_EXCEED_LOAD(60006, "接口负载过高"),
    GET_SMS_CODE_ERROR(60007, "获取短信验证码失败,请稍后再试"),
    COUNT_SMS_CODE_LIMIT_ERROR(60008, "获取短信验证码次数过多,请稍后再试"),
    VALIDATE_SMS_CODE_ERROR(60009, "验证码错误或者为空"),
    USER_NON_SUBSCRIBE(60010, "用户未关注公众号"),
    GET_WX_USER_ERROR(60011, "获取微信授权信息失败"),
    LIMIT_NUM_ERROR(60012, "超出数量限制"),
    INSUFFICIENT_BALANCE(60013, "可提现余额不足"),
    EXCEED_LIMIT(60014, "单人当月累计提现不能超过9.8万，请重新提现或绑定他人银行卡进行提现"),
    FREQUENCY_LIMIT(60016, "当天只允许提现一次，请于明日再来提现"),
    WITHDRAWAL_SUCCESS(60015, "提现成功,佣金将在1~3个工作日内转到您的银行卡中,请注意查收"),
    FORBID_WITHDRAWAL(60017, "该账户禁止提现"),
    QRY_PROCESS_NONE(60022, "未查到信息，请确认客户是否走完申请流程"),
    BANKCARD_ERROR(60026, "信息有误，请重新填写"),
    PRODUCT_MAINTAIN(60027, "该产品维护中，请过段时间再申请"),
    OLD_CUSTOMER(60028, "该客户是老客户，请换产品申请"),
    ORDER_EXISTED(60031, "该订单已存在，无需重复报备"),
    AUTH_FAIL(60032, "获取授权链接失败"),
    ACCOUNT_BALANCE_LESS(60033, "账户余额不足"),
    INVALID_URL(60034, "该链接已失效，请联系管理员"),
    UNPAID_URL(60035, "请先付费"),
    PRODUCT_RULE_LIMIT(60036, "该客户不符合进件要求"),
    ;

    private Integer code;

    private String message;

    ResultCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return this.code;
    }

    public String getMessage() {
        return this.message;
    }

    public static String getMessage(String name) {
        for (ResultCode item : ResultCode.values()) {
            if (item.name().equals(name)) {
                return item.message;
            }
        }
        return name;
    }

    public static Integer getCode(String name) {
        for (ResultCode item : ResultCode.values()) {
            if (item.name().equals(name)) {
                return item.code;
            }
        }
        return null;
    }

    @Override
    public String toString() {
        return this.name();
    }

}